/**
 * "Visual Paradigm: DO NOT MODIFY THIS FILE!"
 * 
 * This is an automatic generated file. It will be regenerated every time 
 * you generate persistence class.
 * 
 * Modifying its content may cause the program not work, or your work may lost.
 */

/**
 * Licensee: DuKe TeAm
 * License Type: Purchased
 */
package orm.impl;

import org.orm.*;
import org.hibernate.Query;
import java.util.List;
import orm.*;

public class Palabra_semanticaDAOImpl implements orm.dao.Palabra_semanticaDAO {
	public Palabra_semantica loadPalabra_semanticaByORMID(int ps_id) throws PersistentException {
		try {
			PersistentSession session = orm.LicitacionesPersistentManager.instance().getSession();
			return loadPalabra_semanticaByORMID(session, ps_id);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Palabra_semantica getPalabra_semanticaByORMID(int ps_id) throws PersistentException {
		try {
			PersistentSession session = orm.LicitacionesPersistentManager.instance().getSession();
			return getPalabra_semanticaByORMID(session, ps_id);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Palabra_semantica loadPalabra_semanticaByORMID(int ps_id, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.LicitacionesPersistentManager.instance().getSession();
			return loadPalabra_semanticaByORMID(session, ps_id, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Palabra_semantica getPalabra_semanticaByORMID(int ps_id, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.LicitacionesPersistentManager.instance().getSession();
			return getPalabra_semanticaByORMID(session, ps_id, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Palabra_semantica loadPalabra_semanticaByORMID(PersistentSession session, int ps_id) throws PersistentException {
		try {
			return (Palabra_semantica) session.load(orm.Palabra_semantica.class, new Integer(ps_id));
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Palabra_semantica getPalabra_semanticaByORMID(PersistentSession session, int ps_id) throws PersistentException {
		try {
			return (Palabra_semantica) session.get(orm.Palabra_semantica.class, new Integer(ps_id));
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Palabra_semantica loadPalabra_semanticaByORMID(PersistentSession session, int ps_id, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			return (Palabra_semantica) session.load(orm.Palabra_semantica.class, new Integer(ps_id), lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Palabra_semantica getPalabra_semanticaByORMID(PersistentSession session, int ps_id, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			return (Palabra_semantica) session.get(orm.Palabra_semantica.class, new Integer(ps_id), lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Palabra_semantica[] listPalabra_semanticaByQuery(String condition, String orderBy) throws PersistentException {
		try {
			PersistentSession session = orm.LicitacionesPersistentManager.instance().getSession();
			return listPalabra_semanticaByQuery(session, condition, orderBy);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Palabra_semantica[] listPalabra_semanticaByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.LicitacionesPersistentManager.instance().getSession();
			return listPalabra_semanticaByQuery(session, condition, orderBy, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Palabra_semantica[] listPalabra_semanticaByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Palabra_semantica as Palabra_semantica");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			List list = query.list();
			return (Palabra_semantica[]) list.toArray(new Palabra_semantica[list.size()]);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Palabra_semantica[] listPalabra_semanticaByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Palabra_semantica as Palabra_semantica");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			query.setLockMode("this", lockMode);
			List list = query.list();
			return (Palabra_semantica[]) list.toArray(new Palabra_semantica[list.size()]);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Palabra_semantica loadPalabra_semanticaByQuery(String condition, String orderBy) throws PersistentException {
		try {
			PersistentSession session = orm.LicitacionesPersistentManager.instance().getSession();
			return loadPalabra_semanticaByQuery(session, condition, orderBy);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Palabra_semantica loadPalabra_semanticaByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.LicitacionesPersistentManager.instance().getSession();
			return loadPalabra_semanticaByQuery(session, condition, orderBy, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Palabra_semantica loadPalabra_semanticaByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
		Palabra_semantica[] palabra_semanticas = listPalabra_semanticaByQuery(session, condition, orderBy);
		if (palabra_semanticas != null && palabra_semanticas.length > 0)
			return palabra_semanticas[0];
		else
			return null;
	}
	
	public Palabra_semantica loadPalabra_semanticaByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		Palabra_semantica[] palabra_semanticas = listPalabra_semanticaByQuery(session, condition, orderBy, lockMode);
		if (palabra_semanticas != null && palabra_semanticas.length > 0)
			return palabra_semanticas[0];
		else
			return null;
	}
	
	public static java.util.Iterator iteratePalabra_semanticaByQuery(String condition, String orderBy) throws PersistentException {
		try {
			PersistentSession session = orm.LicitacionesPersistentManager.instance().getSession();
			return iteratePalabra_semanticaByQuery(session, condition, orderBy);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static java.util.Iterator iteratePalabra_semanticaByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.LicitacionesPersistentManager.instance().getSession();
			return iteratePalabra_semanticaByQuery(session, condition, orderBy, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static java.util.Iterator iteratePalabra_semanticaByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Palabra_semantica as Palabra_semantica");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			return query.iterate();
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static java.util.Iterator iteratePalabra_semanticaByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Palabra_semantica as Palabra_semantica");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			query.setLockMode("this", lockMode);
			return query.iterate();
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Palabra_semantica createPalabra_semantica() {
		return new orm.Palabra_semantica();
	}
	
	public boolean save(orm.Palabra_semantica palabra_semantica) throws PersistentException {
		try {
			orm.LicitacionesPersistentManager.instance().saveObject(palabra_semantica);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean delete(orm.Palabra_semantica palabra_semantica) throws PersistentException {
		try {
			orm.LicitacionesPersistentManager.instance().deleteObject(palabra_semantica);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean refresh(orm.Palabra_semantica palabra_semantica) throws PersistentException {
		try {
			orm.LicitacionesPersistentManager.instance().getSession().refresh(palabra_semantica);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean evict(orm.Palabra_semantica palabra_semantica) throws PersistentException {
		try {
			orm.LicitacionesPersistentManager.instance().getSession().evict(palabra_semantica);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Palabra_semantica loadPalabra_semanticaByCriteria(Palabra_semanticaCriteria palabra_semanticaCriteria) {
		Palabra_semantica[] palabra_semanticas = listPalabra_semanticaByCriteria(palabra_semanticaCriteria);
		if(palabra_semanticas == null || palabra_semanticas.length == 0) {
			return null;
		}
		return palabra_semanticas[0];
	}
	
	public Palabra_semantica[] listPalabra_semanticaByCriteria(Palabra_semanticaCriteria palabra_semanticaCriteria) {
		return palabra_semanticaCriteria.listPalabra_semantica();
	}
}
